@extends('layouts.accountmanage')

@section('title', '个人中心')

@section('header')
	@include('layouts.header-two')
@endsection

@section('content')
<div class="wrapper-container">
		<div class="orderManage-wrapper">
			<div class="orderManage-title">
				<div class="container">
					<h2>用户管理中心</h2>
				</div>
			</div>
			<div class="orderManage-tab">
				<div class="container">
					<div class="row">
						<div class="col-md-2">
							<div class="orderManage-in">
								<a class="manage-active" href="#">资料管理</a>
								<a href="{{ route('userorders')}}">订单管理</a>
								<a href="{{ route('userrecharge')}}">余额管理</a>
							</div>
						</div>
						<div class="col-md-10">
							<div class="orderManage-inner">
								<div class="basic-data">
									<h3>基本资料</h3>
									<ul>
										<li>用户名称：<span>{{ Auth::user()->name }}</span></li>
										<li>手机号码：
										@if (Auth::user()->telephone)
											<span>
												{{ Auth::user()->telephone }}
											</span>
										@else
											<span>
												无
											</span>
										@endif

											<a class="pRevise" href="{{ route('reviseMobile.verify')}}">修改手机</a>
										</li>
										<li>登录方式：<i class="icon-wechat-default"></i><i class="icon-qq-default"></i><i class="icon-weibo-default"></i></li>
									</ul>
								</div>
								<div class="basic-data">
									<h3>其他资料</h3>
									<form method="post" action="{{ route('setuserprofiles') }}" id="userprofiles">
										{{ csrf_field() }}
										<div class="form-group">
										    <label class="control-label">性别：</label>
									      	<label class="radio-inline">
										  		<input type="radio" name="sex" value="f" @if($profiles['gender'] == 'f' || empty($profiles['gender'])) checked="" @endif>男
											</label>
											<label class="radio-inline">
										  		<input type="radio" name="sex" value="w" @if($profiles['gender'] == 'w') checked="" @endif>女
											</label>
									  	</div>
										<div class="form-group">
										    <label class="control-label">地区：</label>
											<div data-toggle="distpicker" class="city">
											  	<select id="cmbProvince"></select>
												<select id="cmbCity"></select>
												<select id="cmbArea"></select>
											</div>
											<input class="ipt_txt street" name="street" type="text" value="{{ $profiles['address']['street']}}" placeholder="请输入具体地址" required/>
											<input name="province" value="{{ $profiles['address']['province'] }}" type="hidden"/>
											<input name="city" value="{{ $profiles['address']['city'] }}"  type="hidden"/>
											<input name="district" value="{{ $profiles['address']['district'] }}"  type="hidden"/>
									  	</div>
										<div class="form-group">
										    <label class="control-label">行业：</label>
											<select class="industry" id="industry1" name="industry1">
    											<option value='-1'>==请选择==</option>
											</select>
											<select class="industry" id="industry2" name="industry2">
													@if($profiles['industry']['industry2'])
														<option value="{{ $profiles['industry']['industry2']}}">{{ $profiles['industry']['industry2']}}</option>
 											    	@else
														<option value='-1'>==请选择==</option>
													@endif
											</select>
									  	</div>
									  	<button type="button" class="saveuserinfo">保存</button>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
@endsection

@section('script')
	<script src="{{ asset('statics/js/jsAddress.js') }}" ></script>
	<script>
			addressInit('cmbProvince', 'cmbCity', 'cmbArea', "{{ $profiles['address']['province'] }}", "{{ $profiles['address']['city'] }}", "{{ $profiles['address']['district'] }}");
			$(function(){
				var h1=$(".orderManage-in").height();
				var h2=$(".orderManage-inner").height();
				if(h2>h1){
					$(".orderManage-in").height($(".orderManage-inner").height());
				}
			})
			$(document).ready(function(){
				var province= $('#cmbProvince').children(' option:selected').val();//这就是selected的值
				$('input[name="province"]').val(province);
				var city=$('#cmbCity').children('option:selected').val();//这就是selected的值
				$('input[name="city"]').val(city);

				var district=$('#cmbArea').children('option:selected').val();//这就是selected的值
				$('input[name="district"]').val(district);

				$('#cmbProvince').change(function(){
					var province= $(this).children('option:selected').val();//这就是selected的值
					console.log(province);
					$('input[name="province"]').val(province);
				});
				$('#cmbCity').change(function(){
					var city=$(this).children('option:selected').val();//这就是selected的值
					$('input[name="city"]').val(city);
				});
				$('#cmbArea').change(function(){
					var district=$(this).children('option:selected').val();//这就是selected的值
					$('input[name="district"]').val(district);
				});
			});
			$(function(){
				jQuery('.street').bind({
					focus:function(){
						if (this.value == this.defaultValue){
							this.value="";
						};
						$(this).css("color","#666");
					},
					blur:function(){
						if (this.value == ""){
							this.value = this.defaultValue;
							$(this).css("color","#999");
						}else{
							$(this).css("color","#666");
						};
					}
				});
			})
			$(function(){
				var ss;
			    $.getJSON("/statics/js/mydata.json",function(data){
			        ss=data;
			        @if ($profiles['industry'])
			        	var html="<option value=\"{{ $profiles['industry']['industry1']}}\">{{ $profiles['industry']['industry1']}}</option>" ;
				    @else
					    var html="<option value='-1'>==请选择==</option>";
					@endif
// 					var html="<option value='-1'>==请选择==</option>";
			        for(var i=0;i<ss.length;i++){
			          html+="<option value='"+ss[i].p+"'>"+ss[i].p+"</option>";
			        }
			        $("#industry1").html(html);
			    });
			    $("#industry1").change(function(){
			        var htmls="<option value='-1'>==请选择==</option>";
			        for(var i=0;i<ss.length;i++){
			            if($(this).val()==ss[i].p){
			                var a=ss[i].c;
			                for(var j=0;j<a.length;j++){
			                    htmls+="<option value='"+a[j].c1+"'>"+a[j].c1+"</option>";
			                }
			                $("#industry2").html(htmls);
			            }
			        }
			    })
			})
		</script>
		<script language="javascript" type="text/javascript">
		$('.saveuserinfo').click(function(){
			$.ajax({
	            type: "POST",
	            url: "{{ route('setuserprofiles') }}",
	            data: $('#userprofiles').serialize(),
	            success: function(data) {
	            	alert('保存成功');
	            },
	            complete: function() {

	            }
	        });
		});
	</script>
@endsection

@section('footer')
	@include('layouts.footer-short')
@endsection
